﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Viki_IDal;
using Viki_Model;

namespace Viki_DAL
{
    public class RegisterDao:IRegisterDao
       
    {
        public void add(string register_email, string register_pwd, string register_tel, string register_recommender, DateTime register_time)
        {
            RegisterDataContext registerdata = new RegisterDataContext();
            UserDataContext userdata = new UserDataContext();
            User user = new User();
            Register register = new Register();

            Guid guid = new Guid();
            string id=guid.ToString();
            string number = new Random().Next().ToString();
            register.register_id = id;
            register.register_email = register_email;
            register.register_pwd = register_pwd;
            register.register_tel = register_tel;
            register.register_recommender = register_recommender;
            register.register_time = register_time;
            registerdata.Register.InsertOnSubmit(register);
            registerdata.SubmitChanges();
            user.user_id = id;
            user.user_email = register_email;
            user.user_pwd = register_pwd;
            user.user_power = "0";
            user.user_count = 1;
            user.user_number = number;
            user.user_login_time = register_time;
            userdata.User.InsertOnSubmit(user);
            userdata.SubmitChanges();
        }
    }
}
